import numpy as np
from sklearn.metrics import log_loss

train_features = np.load('data/train_features.npy', allow_pickle=True)
train_labels = np.load('data/train_labels.npy', allow_pickle=True)
test_features = np.load('data/test_features.npy', allow_pickle=True)

from sklearn.naive_bayes import BernoulliNB

model = BernoulliNB()
model.fit(train_features, train_labels)
predicted = np.array(model.predict_proba(train_features))
print("朴素贝叶斯的log损失为 %f" % (log_loss(train_labels, predicted)))

if __name__ == '__main__':
    print()
